package com.financial.business.balance.service.impl;

import com.financial.business.balance.constants.FinancialRefundBalanceEnumConstants;
import com.financial.business.balance.service.FinancialBalanceRefundService;
import com.financial.business.balance.service.gy.FinancialGYBalanceRefundService;
import com.financial.business.balance.utils.JsonUtils;
import com.financial.business.balance.utils.apiresult.ApiResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @Author WANGNING
 * @Email wyn20140226@aliyun.com
 * @Description //余额退款业务处理
 * @Date 2019/12/4 10:29
 */
@Service
public class FinancialBalanceRefundServiceImpl implements FinancialBalanceRefundService {

    protected static final Logger logger= LoggerFactory.getLogger(FinancialBalanceRefundServiceImpl.class);

    @Autowired
    private FinancialGYBalanceRefundService financialGYBalanceRefundService;

    @Override
    public ApiResult refund(String requestParam) {
        logger.info("FinancialBalanceRefundServiceImpl.refund()-----余额退款获取到的json信息为："+requestParam);
        /*解析参数信息判断支付渠道*/
        Map<String,Object> map = JsonUtils.jsonToMap(requestParam);
        String payChannelNo=(String)map.get("pay_channel_no");
        logger.info("FinancialBalanceRefundServiceImpl.refund()-----支付渠道为："+payChannelNo);
        ApiResult apiResult=ApiResult.failure(FinancialRefundBalanceEnumConstants.ENUM_PAYCHANNEL_GYBALANCE);
        /*判断支付渠道*/
        if(payChannelNo.equalsIgnoreCase(FinancialRefundBalanceEnumConstants.ENUM_PAYCHANNEL_GYBALANCE)){
            /*够样平台余额支付*/
            apiResult=financialGYBalanceRefundService.refund(requestParam);
        }
        return apiResult;
    }
}
